function CGame(oData) {
    var _pStartPosAudio;
    var _pStartPosPlay;
    var _pStartPosInfo;
    var _oBg;
    var _oFBg;
    var _oButPlay;
    var _oButInfo;
    var _oFade;
    var _oAudioToggle;
    var _oContainerStack;
    var _oLeft;
    var _oRight;
    var _btnreset;

    var _btnhome;
    var _btnpredis;
    var _btnnxtdis;
    var _oBlackboard;
    var _oBlackboardtuttom;
    var _btnpre;
    var _btnnxt;
    var _btnsetting;
    var _curPage;
    var _maxPage;
    var _pageSize = 4;
    var _thisData;
    var _text;
    var _title;
    var _oPointer;
    var _d;
    this._init = function () {
        _oContainerStack = new createjs.Container();
        s_oStage.addChild(_oContainerStack);

        // _oFBg = createBitmap(s_oSpriteLibrary.getResult('bg'));
        // _oContainerStack.addChild(_oFBg);
        _oLeft = createBitmap(s_oSpriteLibrary.getResult('zhu'));
        _oLeft.x = 144 + 350/2;
        _oLeft.y = 70;

        _oRight = createBitmap(s_oSpriteLibrary.getResult('zhu'));

        _oRight.x = 514 + 350/2;
        _oRight.y = 70;

        _oBlackboardtuttom = createBitmap(s_oSpriteLibrary.getResult('blackboardtuttom'));
        _oBlackboard = createBitmap(s_oSpriteLibrary.getResult('blackboardtop'));


        _btnhome = createBitmap(s_oSpriteLibrary.getResult('home'));
        _btnhome.x = 150;
        _btnhome.y = 3;
        _btnhome.on("mousedown", this.homeButtonDown);
        _btnhome.on("pressup", this.homeButtonRelease);

        _btnreset = createBitmap(s_oSpriteLibrary.getResult('reset'));
        _btnreset.x = 420;
        _btnreset.y = 3;


        _btnpre = createBitmap(s_oSpriteLibrary.getResult('pre'));
        _btnpre.x = 550;
        _btnpre.y = 3;
        _btnpre.on("mousedown", this.preButtonDown);
        _btnpre.on("pressup", this.preButtonRelease);

        _btnpredis = createBitmap(s_oSpriteLibrary.getResult('pre-dis'));
        _btnpredis.x = 550;
        _btnpredis.y = 3;

        _btnnxt = createBitmap(s_oSpriteLibrary.getResult('next'));
        _btnnxt.x = 690;
        _btnnxt.y = 3;
        _btnnxt.on("mousedown", this.nxtButtonDown);
        _btnnxt.on("pressup", this.nxtButtonRelease);
        _btnnxtdis = createBitmap(s_oSpriteLibrary.getResult('nxt-dis'));
        _btnnxtdis.x = 690;
        _btnnxtdis.y = 3;


        _btnsetting = createBitmap(s_oSpriteLibrary.getResult('star'));
        _btnsetting.x = 830;
        _btnsetting.y = 3;

        _btnsetting.on("mousedown", this.settingButtonDown);
        _btnsetting.on("pressup", this.settingButtonRelease);

        if (DISABLE_SOUND_MOBILE === false || s_bMobile === false) {
            var _btnshengyin = s_oSpriteLibrary.getResult('soundsprite');
            _pStartPosAudio = {x: CANVAS_WIDTH - (_btnshengyin.height / 2) - 15, y: (_btnshengyin.height / 2) + 13};
            _oAudioToggle = new CToggle(300, (_btnshengyin.height / 2) + 5, _btnshengyin, s_bAudioActive, _oContainerStack);
            _oAudioToggle.addEventListener(ON_MOUSE_UP, this._onAudioToggle, this);
        }

        this._initPage(_thisData);
        this._reflush();

        this.setToolsStatus();
    };

    /**
     * 设置菜单状态
     */
    this.setToolsStatus = function () {
        if (_curPage == 1) {
            _btnpre.visible = false;
            _btnpredis.visible = true;
        } else {
            _btnpre.visible = true;
            _btnpredis.visible = false;
        }
        if (_curPage == _maxPage) {
            _btnnxt.visible = false;
            _btnnxtdis.visible = true;
        } else {
            _btnnxt.visible = true;
            _btnnxtdis.visible = false;
        }
    };

    this._initPage = function (oData) {
        var linenum = oData.length;
        _maxPage = Math.ceil(linenum / _pageSize);
        _curPage = 1;
    };

    this._reflush = function () {
        if (_curPage < 1)
            return "";
        // _oContainerStack.removeAllChildren();

        var begin = (_curPage - 1) * _pageSize;
        var end = _curPage * _pageSize;
        if (_curPage >= _maxPage) {
            end = Math.min(_curPage * _pageSize, _thisData.length);
        }

        if (s_oLeftTop) {
            s_oLeftTop.unload();
        }
        if (s_oRigthTop) {
            s_oRigthTop.unload();
        }
        if (s_oLeftBottom) {
            s_oLeftBottom.unload();
        }
        if (s_oRightBottom) {
            s_oRightBottom.unload();
        }

        for (var i = end; i < _curPage * _pageSize; i++) {
            if (i % 4 == 0) {
                s_oLeftTop = new CNotFlip(155, 80, s_oSpriteLibrary.getResult('lefttop'), _oContainerStack, 350);
            } else if (i % 4 == 1) {
                s_oRigthTop = new CNotFlip(525, 80, s_oSpriteLibrary.getResult('righttop'), _oContainerStack, 350);
            } else if (i % 4 == 2) {
                s_oLeftBottom = new CNotFlip(155, 390, s_oSpriteLibrary.getResult('leftbottom'), _oContainerStack, 350);
            } else if (i % 4 == 3) {
                s_oRightBottom = new CNotFlip(525, 390, s_oSpriteLibrary.getResult('rightbottom'), _oContainerStack, 350);
            }
        }
        //for (var i = begin; i < end; i++, index++) {
        for (var i = end - 1; i >= begin; i--) {
            if (i % 4 == 0) {
                s_oLeftTop = new CFlip(155, 80, _thisData[i].dspTxt, _thisData[i].dspSubTxt, s_oSpriteLibrary.getResult('lefttop'), s_oSpriteLibrary.getResult('_key' + _thisData[i].key), _oContainerStack, 350);
            } else if (i % 4 == 1) {
                s_oRigthTop = new CFlip(525, 80, _thisData[i].dspTxt, _thisData[i].dspSubTxt, s_oSpriteLibrary.getResult('righttop'), s_oSpriteLibrary.getResult('_key' + _thisData[i].key), _oContainerStack, 350);
            } else if (i % 4 == 2) {
                s_oLeftBottom = new CFlip(155, 390, _thisData[i].dspTxt, _thisData[i].dspSubTxt, s_oSpriteLibrary.getResult('leftbottom'), s_oSpriteLibrary.getResult('_key' + _thisData[i].key), _oContainerStack, 350);
            } else if (i % 4 == 3) {
                s_oRightBottom = new CFlip(525, 390, _thisData[i].dspTxt, _thisData[i].dspSubTxt, s_oSpriteLibrary.getResult('rightbottom'), s_oSpriteLibrary.getResult('_key' + _thisData[i].key), _oContainerStack, 350);
            }
        }

        _oContainerStack.removeAllChildren();
        _oContainerStack.addChild(_oLeft);
        _oContainerStack.addChild(_oRight);
        _oContainerStack.addChild(_oBlackboardtuttom);
        _oContainerStack.addChild(s_oLeftBottom.child());
        _oContainerStack.addChild(s_oRightBottom.child());
        _oContainerStack.addChild(s_oLeftTop.child());
        _oContainerStack.addChild(s_oRigthTop.child());


        _oContainerStack.addChild(_oBlackboard);
        _oContainerStack.addChild(_btnhome);
        _oContainerStack.addChild(_btnpre);
        _oContainerStack.addChild(_btnpredis);
        _oContainerStack.addChild(_btnnxt);
        _oContainerStack.addChild(_btnnxtdis);
        _oContainerStack.addChild(_btnsetting);
        _oContainerStack.addChild(_oAudioToggle.child());
        _oContainerStack.addChild(_btnreset);
    };

    this.homeButtonDown = function () {
        _btnhome.scaleX = 0.9;
        _btnhome.scaleY = 0.9;
    };
    this.homeButtonRelease = function () {
        _btnhome.scaleX = 1;
        _btnhome.scaleY = 1;

        window.open($('#ctxContent').val() + "/front/home/" + $('#classId').val() + ".shtml", "_self");
    };

    this.nxtButtonDown = function () {
        _btnnxt.scaleX = 0.9;
        _btnnxt.scaleY = 0.9;
    };
    this.nxtButtonRelease = function () {
        _btnnxt.scaleX = 1;
        _btnnxt.scaleY = 1;

        _curPage++;
        if (_curPage > _maxPage) {
            _curPage = _maxPage;
            s_oGame.setToolsStatus();
            return;
        }
        s_oGame.setToolsStatus();
        s_oGame._reflush();
    };

    this.preButtonDown = function () {
        _btnpre.scaleX = 0.9;
        _btnpre.scaleY = 0.9;
    };
    this.preButtonRelease = function () {
        _btnpre.scaleX = 1;
        _btnpre.scaleY = 1;

        _curPage--;
        if (_curPage < 1) {
            _curPage = 1;
            s_oGame.setToolsStatus();
            return;
        }
        s_oGame.setToolsStatus();
        s_oGame._reflush();
    };

    this.settingButtonDown = function () {
        _btnsetting.scaleX = 0.9;
        _btnsetting.scaleY = 0.9;
    };
    this.settingButtonRelease = function () {
        _btnsetting.scaleX = 1;
        _btnsetting.scaleY = 1;

        //playSound("click", 1, 0);

        //stopSound(_oPointer);
        //_oContainerStack.removeAllChildren();

        //s_oGame = null;
        // s_oMenu.setVisible(true);
        window.open($('#ctxContent').val() + "/front/middle/" + $('#classId').val() + "/" + $('#originalId').val() + ".shtml", "_self");
    };

    this.unload = function () {
        _oButPlay.unload();
        _oButPlay = null;

        _oButInfo.unload();
        _oButInfo = null;

        if (DISABLE_SOUND_MOBILE === false || s_bMobile === false) {
            _oAudioToggle.unload();
            _oAudioToggle = null;
        }

        s_oStage.removeAllChildren();

        s_oGame = null;
    };

    this.fadeAnim = function () {
        var oParent = this;
        _oFade.visible = true;
        createjs.Tween.get(_oFade, {override: true}).to({alpha: 1}, MS_FADE_ANIM, createjs.Ease.cubicIn).call(function () {
            oParent.unload();
            s_oMain.gotoGame();
        });
    };

    this.changeText = function(txt, title) {
        createjs.Tween.get(_text.getSelf(),{loop:false},true)
            .to({alpha:0},1000,createjs.Ease.linear)
            .call(function () {
                _text.setText(txt);
                createjs.Tween.get(_text.getSelf(),{loop:false},true)
                    .to({alpha:1},1000,createjs.Ease.linear)
            });

        createjs.Tween.get(_title.getSelf(),{loop:false},true)
            .to({alpha:0},1000,createjs.Ease.linear)
            .call(function () {
                _title.setText(title);
                createjs.Tween.get(_title.getSelf(),{loop:false},true)
                    .to({alpha:1},1000,createjs.Ease.linear)
            });
    };

    _thisData = oData;
    s_oGame = this;
    this._init();
}

var s_oGame = null;